<template>
  <el-dialog
    title="开户信息"
    :visible.sync="dialogVisible"
    :show="show"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    @open='open'
    @close="$emit('update:show',false)"
  >
    <el-scrollbar ref="myScrollbar" :wrap-class="{wrapClass: true}">
      <div class="el-dialog-div">
        <el-table
          v-loading="infoLoding"
          :data="list"
          element-loading-text="Loading"
          fit
          border
          size="medium"
          style="margin-bottom: 20px"
          :height="listQuery.total>0 ? 'calc(100vh - 400px)' : 'calc(100vh - 400px)'"
          :header-cell-style="{background: '#F2F6FC'}"
        >
          <el-table-column align="center" fixed="left" label="序号" width="50" type="index">
          </el-table-column>
          <el-table-column align="center" min-width="110px">
            <template slot="header">
              用户名
              <el-tooltip class="item" effect="dark" content="员工账户用户名" placement="top">
                <i class="el-icon-question"></i>
              </el-tooltip>
            </template>
            <template slot-scope="scope">
              {{ scope.row.userName }}
            </template>
          </el-table-column>
          <el-table-column align="center" min-width="110px">
            <template slot="header">
              用户姓名
              <el-tooltip class="item" effect="dark" content="员工账户用户姓名" placement="top">
                <i class="el-icon-question"></i>
              </el-tooltip>
            </template>
            <template slot-scope="scope">
              {{ scope.row.trueName }}
            </template>
          </el-table-column>
          <el-table-column label="创建时间" width="155px" align="center">
            <template slot-scope="scope">
              {{ scope.row.createdAt }}
            </template>
          </el-table-column>
        </el-table>
        <pagination
          style="margin-bottom: 15px;"
          v-show="listQuery.total>0"
          :total="listQuery.total"
          :page.sync="listQuery.page"
          :limit.sync="listQuery.limit"
          @pagination="open"
        />
      </div>
    </el-scrollbar>
  </el-dialog>
</template>

<style scoped>
/deep/ .el-dialog {
  min-width: 470px;
  max-width: 1000px;
}

/deep/ .el-dialog__body {
  padding: 0;
}

.el-dialog-div {
  padding: 20px 20px 0 20px;
  min-width: 400px;
}
</style>
<script>
import Pagination from '@/components/Pagination'
import { getAction } from '@/api/common'
export default {
  props: {
    show: {
      type: Boolean,
      default: false
    },
    companyId: {
      type: [Number, String],
      default: ''
    }
  },
  data() {
    return {
      list: null,
      listQuery: {
        page: 1,
        total: 0,
        limit: 10,
        id: ''
      },
      dialogVisible: this.show,
      infoLoding: true
    }
  },
  components: {
    Pagination
  },
  methods: {
    async open() {
      this.infoLoding = true
      this.listQuery.id = this.companyId
      const { data } = await getAction(this.listQuery, 'Junior/GetJuniorEmployeeList')
      this.list = data.items
      this.listQuery.total = data.total

      this.infoLoding = false
    }
  },
  watch: {
    show() {
      this.dialogVisible = this.show
    }
  }
}
</script>
